package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PatientVisits;
import com.ruoyi.system.service.IPatientVisitsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核酸预约检测Controller
 * 
 * @author ruoyi
 * @date 2025-06-30
 */
@RestController
@RequestMapping("/system/visits")
public class PatientVisitsController extends BaseController
{
    @Autowired
    private IPatientVisitsService patientVisitsService;

    /**
     * 查询核酸预约检测列表
     */
    @PreAuthorize("@ss.hasPermi('system:visits:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatientVisits patientVisits)
    {
        startPage();
        List<PatientVisits> list = patientVisitsService.selectPatientVisitsList(patientVisits);
        return getDataTable(list);
    }

    /**
     * 导出核酸预约检测列表
     */
    @PreAuthorize("@ss.hasPermi('system:visits:export')")
    @Log(title = "核酸预约检测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientVisits patientVisits)
    {
        List<PatientVisits> list = patientVisitsService.selectPatientVisitsList(patientVisits);
        ExcelUtil<PatientVisits> util = new ExcelUtil<PatientVisits>(PatientVisits.class);
        util.exportExcel(response, list, "核酸预约检测数据");
    }

    /**
     * 获取核酸预约检测详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:visits:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(patientVisitsService.selectPatientVisitsById(id));
    }

    /**
     * 新增核酸预约检测
     */
    @PreAuthorize("@ss.hasPermi('system:visits:add')")
    @Log(title = "核酸预约检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientVisits patientVisits)
    {
        return toAjax(patientVisitsService.insertPatientVisits(patientVisits));
    }

    /**
     * 修改核酸预约检测
     */
    @PreAuthorize("@ss.hasPermi('system:visits:edit')")
    @Log(title = "核酸预约检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientVisits patientVisits)
    {
        return toAjax(patientVisitsService.updatePatientVisits(patientVisits));
    }

    /**
     * 删除核酸预约检测
     */
    @PreAuthorize("@ss.hasPermi('system:visits:remove')")
    @Log(title = "核酸预约检测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(patientVisitsService.deletePatientVisitsByIds(ids));
    }
}
